//外接订单详情（disable）
/**
 * 主视图
 */
interface IcspOrderDetailDisableController extends ng.IScope {
    /**
    * 所需车型下拉
    */
    carTypeDropDown: ValueListItemResponse[];
    /**
    * 所需车长下拉
    */
    carLengthDropDown: ValueListItemResponse[];
    /**
    * 承运方式下拉
    */
    carrierCategoryDropDown: ValueListItemResponse[];
    /**
     * 总单信息对象
     */
    OData: cspOrderDetailResponse;
    /**
    * 总单列表数据对象
    */
    orderTotalList: Array<cspOrderDetailResponse>;
    /**
    * 子单列表数据对象
    */
    orderChildrenList: Array<CspOrderChildList>;
    /**
     *总单详情对象
     */
    orderDetial: cspOrderDetailResponse;
    /**
    * 子单详情对象
    */
    orderChil: CspOrderChildList;
    /**
    * 点击获取总单详情事件
    */
    getOrderDetial: (data: cspOrderDetailResponse) => void;
    /**
    * 点击获取子单详情事件
    */
    EditChildren: (data: CspOrderChildList) => void;
    /**
     * 驾驶证上传组件
     */
    driverUploader: any;
    /**
     * 返回事件
     */
    backUrl:()=>void
}



class cspOrderDetailDisableController {
    uploaderList: AddCarAttachmentDetail[];

    baseImageUrl: string;
    /**
     *订单id
     */
    id: string;
    /**
     *名称
     */
    name: string;
    /**
     *订单状态
     */
    type: string;
    /**
     *承运商id
     */
    carrierId: string;

    constructor(private $scope: IcspOrderDetailDisableController,
        private routeService: routeService,
        
        private valueService: IValueService,
        private $state: angular.ui.IStateService,
        private $location: ng.ILocationService,
        private $http: ng.IHttpService,
        private $ngBootbox: BootboxService,
        private commonService:ICommonService,private cspOrderService:IcspOrderService,private ossUploaderService:ossUploaderService) {
        this.baseImageUrl = this.routeService.getBaseUrl() + "attachment/";
        this.uploaderList = [];
        this.init();
    }

    init = () => {
        this.id = this.$location.search().id;
        this.name = this.$location.search().name;
        this.$scope.backUrl=this.backUrl;

      

        const OssFile = this.ossUploaderService.getOssFile();
        this.$scope.driverUploader= new OssFile(this.$scope,this.$scope.driverUploader,{uploaderList:this.uploaderList,tag:1,multiple:true});
        

        this.loadValueDropDown();
        this.getCspOrderDetail();

        this.$scope.getOrderDetial = this.getOrderDetial;
        this.$scope.EditChildren = this.EditChildren;

    }

    
    getCspOrderDetail=()=>{
        this.cspOrderService.cspOrderDetail(this.id).then(res=>{
            this.$scope.OData = res.data;
            this.getCspOrderTotalData(res.data);

            //附件
            res.data.attachmentList.forEach((item, index) => {
                // this.commonService.showFileItem(item, this.$scope.driverUploader);
                this.$scope.driverUploader.addByAttach(item)
                this.uploaderList.push({
                    attachmentId:item.attachmentId,
                    attachmentName:item.attachmentName,
                    attachmentPath:item.attachmentPath,
                    attachmentTag:item.attachmentTag
                });
            });

        });
    }
    
    /**
     * 获取总单子单列表
     */
    getCspOrderTotalData=(data:cspOrderDetailResponse)=>{
        this.$scope.orderTotalList = [data];
        this.$scope.orderChildrenList = data.items;
    }
    
    /**
     * 查看总单详情
     */
    getOrderDetial=(data:cspOrderDetailResponse)=>{
        this.$scope.orderDetial = data;
    }
    /**
     * 查看子单详情
     */
    EditChildren = (data) =>{
        this.$scope.orderChil = data;
    }


    /** 
     * 填充所有静态下拉事件(
     */
    loadValueDropDown(): void {
        this.$scope.carTypeDropDown = this.valueService.getCarTypeList().data;
        this.$scope.carLengthDropDown = this.valueService.getCarLengthList().data;
        this.$scope.carrierCategoryDropDown = this.valueService.getCarrierWayList().data;
    }


     /**
     * 返回事件
     */
    backUrl=()=>{
        this.$state.go('app.order.external_order',{ name:'Edit'});
    }

}

angular.module("tms").controller("cspOrderDetailDisableController", ['$scope', 'routeService',
    'valueService',
    '$state',
    '$location',
    '$http',
    '$ngBootbox','commonService','cspOrderService','ossUploaderService',
    cspOrderDetailDisableController]);